package program.utils;

import java.text.DecimalFormat;

/**
 * @program: OSAlgorithms
 * @description: 计算工具类
 * @author: Echo-dev
 * @create: 2021-11-10 17:49
 **/
public class MathUtil {

    public static Double getPercent(int x,int y){
        double d1 = x * 1.0;
        double d2 = y * 1.0;
        // 设置保留几位小数， “.”后面几个零就保留几位小数，这里设置保留四位小数
        DecimalFormat decimalFormat = new DecimalFormat("##.0000");
        Double pre = Double.valueOf(decimalFormat.format(d1/d2));
        return pre;
    }

}
